home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 4902 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.7 KB

  1. Path: mail2news.demon.co.uk!vsoft.demon.co.uk
  2. From: Rik Barker <R-Barker@vsoft.demon.co.uk>
  3. Newsgroups: comp.lang.c++
  4. Subject: Help! problem with open()
  5. Date: Thu, 01 Feb 1996 12:24:24 GMT
  6. Organization: Visionsoft Limited
  7. Message-ID: <608213585wnr@vsoft.demon.co.uk>
  8. Reply-To: R-Barker@vsoft.demon.co.uk
  9. X-NNTP-Posting-Host: vsoft.demon.co.uk
  10. X-Broken-Date: Thursday, Feb 01, 1996 12.24.24
  11. X-Newsreader: Newswin Alpha 0.7
  12. X-Mail2News-Path: disperse.demon.co.uk!post.demon.co.uk!vsoft.demon.co.uk
  13.  
  14. Hi,
  15.  
  16. I've got a really odd problem with open().
  17. The code I have works on 90% of the PCs I try it on, and fails on
  18. Dells, some AST, and some ACER PCs.
  19.  
  20. Does anyone know a way around this?  It's quite urgent.
  21.  
  22.  
  23. Here's the code that fails.
  24. It fails when Opening the file for writing.  I stuck perror() in and 
  25. got back "Invalid Argument"
  26.  
  27. Both FromTwo, and FileTwo are char *
  28. Any help _Hugely_ Appreciated, I'm baffled.
  29.  
  30. Cheers,
  31. Rik.
  32.  
  33. *******************************************
  34.  if ((xin=open(FromTwo,O_RDONLY | O_BINARY))== -1)
  35.  {
  36.       printf("Error: Problem Reading File (1)\n");
  37.       return FALSE;
  38.  }
  39.  
  40.  if ((xout=open(FileTwo,O_CREAT|O_TRUNC|O_WRONLY|O_BINARY))==-1)        
  41.  {             
  42.     printf("Error: Problem Writing File\n");     
  43.         close(xin);             
  44.     return FALSE;
  45.  }
  46.  else
  47.  {
  48.          while (!eof(xin))
  49.          {
  50.               if ((bytes=read(xin,cbuffer,1024)) == -1)
  51.                  return FALSE;
  52.               else
  53.                  write(xout,cbuffer,bytes);
  54.           }
  55.       close(xin);
  56.       close(xout);
  57. }
  58. ----------------------------------
  59. Any views expressed are my own,
  60. and may not be that of my employer
  61. ----------------------------------
  62. Rik | R-Barker@vsoft.demon.co.uk
  63. ----------------------------------
  64.  
  65.